﻿using System;

namespace ParserGenerator.ParserConstruction
{
    [Serializable]
    public abstract class ParserAutomatonContribution
    {
        public bool IsShift => this is ParserAutomatonShift;
        public bool IsReduction => this is ParserAutomatonReduction;

        public ParserAutomatonShift AsShift => (ParserAutomatonShift)this;
        public ParserAutomatonReduction AsReduction => (ParserAutomatonReduction)this;

        public ParserAutomatonState State { get; }

        internal ParserAutomatonContribution(ParserAutomatonState state)
        {
            if (state == null)
                throw new ArgumentNullException(nameof(state));
            State = state;
        }
    }
}
